package com.cloudfun.campusshare.controller;

import com.cloudfun.campusshare.common.response.BaseResult;
import com.cloudfun.campusshare.common.response.BaseResultFactory;
import com.cloudfun.campusshare.common.security.AuthRequired;
import com.cloudfun.campusshare.service.BankInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author : zhangyongjie
 * @version : 1.0
 * @createTime : 2020/6/6 17:14
 * @description :
 */
@RestController
@RequestMapping("/v1/bank")
@Api(value = "银行信息")
@Validated
@Slf4j
@AuthRequired
public class BankInfoController {
    @Autowired
    private BankInfoService bankInfoService;

    @GetMapping("/list")
    public BaseResult queryBankList(){
        return BaseResultFactory.produceSuccess(bankInfoService.getBankNameList());
    }

    @GetMapping("/subBank/list")
    public BaseResult queryForkBankNameList(Pageable pageable, @ApiParam(value = "关键字") @RequestParam(required = false)String keyword,
                                            @ApiParam(value = "省份")@RequestParam String province,
                                            @ApiParam(value = "城市")@RequestParam String city,
                                            @ApiParam(value = "银行名称")@RequestParam String bankName){
        return BaseResultFactory.produceSuccess(bankInfoService.getForkBankNameList(pageable,keyword,province,city,bankName));
    }
}
